home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Revista CD Expert 32
/
CD Expert nº 32.iso
/
Army Men TiS
/
data1.cab
/
Required_Files
/
rules
/
it_ai.txt
< prev
next >
Wrap
Text File
|
1999-10-08
|
4KB
|
134 lines
// @1 = color to do AI for, @2 = color of enemy, @3 = value for @1Action variable
macro it_ai_enemy 3
{
// these events setup the @1Action variable
// before attacking @2 make sure @2 is in the game and is not an ally
if @1SetAttack@2 testvar IsColorInGame @2 > 0 and IsAlly @1 @2 = 0 then
setvar @1Action @3,
trigger @1ActionOrders,
trigger @1StartTimeOut
// if @2 not in game pick another action
if @1SetAttack@2 testvar IsColorInGame @2 = 0 then
triggerdelay 1000 @1ChooseAction
// if @2 is an ally pick another action
if @1SetAttack@2 testvar IsAlly @1 @2 = 1 then
triggerdelay 1000 @1ChooseAction
// these events do the actual attack orders
if @1ActionOrders testvar @1Action = @3 then
order @1sarge1 follow @2sarge1 inmode attack,
order @1 group 1 follow @1sarge1 inmode defend,
order @1 group 2 follow @2sarge1 inmode attack,
order @1 group 3 follow @2sarge1 inmode attack,
order @1 group 4 follow @2sarge1 inmode attack,
order @1 group 5 follow @2sarge1 inmode attack
if @1check@2score testvar teamscore @2 >= @1winningScore and IsAlly @1 @2 = 0 then
setvar @1winningScore teamscore @2,
setvar @1winningColor @3
if @1AttackWinningColor testvar @1winningColor = @3 then
trigger @1SetAttack@2
}
// @1 = color of army to do AI for, @2-@4 = other colors
macro it_ai_macro 4
{
// This variable holds the current action for @1
// 0 means no action, 1 means attack @2, 2 means attack @3, 3 means attack @4,
// 4 means go to base
variable @1Action 0
// this variable is set to the winning score if @1 is not winning
variable @1winningScore 0
// this variable is set to the winning color (e.g. green, tan) if @1 is not winning
variable @1winningColor 0
if startup1 then
triggerdelay 1000 @1ChooseNewAction,
triggerdelay 2000 @1RegularOrders
if @1ChooseNewAction then
setvar @1Action 0,
trigger @1ChooseAction
// if @1 has no current action then pick a random action
// keep doing this until an action is set
if @1ChooseAction testvar @1Action = 0 and @1IsOnItTeam = 1 then
trigger @1PickRandomColorToAttack
if @1ChooseAction testvar @1Action = 0 and @1IsOnItTeam = 0 then
trigger @1CalculateWinningTeam,
trigger @1PickNotItAction
if @1PickNotItAction testvar @1winningscore < teamscore @1 then
trigger @1GotoBase
if @1PickNotItAction testvar @1winningscore >= teamscore @1 then
trigger @1AttackWinningColor
if @1CalculateWinningTeam then
setvar @1winningScore 0,
setvar @1winningColor 0,
trigger @1check@2score,
trigger @1check@3score,
trigger @1check@4score
if @1PickRandomColorToAttack then random
trigger @1SetAttack@2,
trigger @1SetAttack@3,
trigger @1SetAttack@4
expand it_ai_enemy ( @1 @2 1 )
expand it_ai_enemy ( @1 @3 2 )
expand it_ai_enemy ( @1 @4 3 )
// this event is for going back to base to defend yourself when not it
if @1GotoBase then
setvar @1Action 4,
trigger @1ActionOrders,
trigger @1StartTimeOut
if @1ActionOrders testvar @1Action = 4 then
order @1sarge1 goto @1base inmode attack,
order @1 group 1 follow @1sarge1 inmode defend,
order @1 group 2 goto near@1base inmode attack,
order @1 group 3 goto near@1base inmode attack,
order @1 group 4 goto near@1base inmode defend,
order @1 group 5 goto near@1base inmode defend
// these events choose new actions if a sarge is killed
if itHasChanged then
triggerdelay 100 @1ChooseNewAction,
triggerdelay 3100 @1ActionOrders // allow time for resurrect
// these are the standing order regardless of what mode sarge is in
if @1RegularOrders then
order @1 group 7 goto @1base inmode defend,
trigger @1ActionOrders,
triggerdelay 5000 @1RegularOrders
// timeout code - if mode has not changed for a while then change it
variable @1TimeOutVar 0
variable @1LastTimeOutVar 1
if @1StartTimeOut then
addvar @1TimeOutVar 1,
triggerdelay 120000 @1CheckTimeOut
if @1CheckTimeOut testvar @1TimeOutVar = @1LastTimeOutVar then
trigger @1ChooseNewAction
if @1CheckTimeOut testvar @1TimeOutVar <> @1LastTimeOutVar then
addvar @1LastTimeOutVar 1
}